﻿/** 
 *   PresentacionA: Letra A para la presentacion del juego.
 *  
 *   @see Presentacion Menu
 *   @author Eduardo Masia Roman
 */

/* --------------------------------------------------         
   Parte de Damas - EMR
   Versiones hasta la fecha:
   
   Num.   Fecha       Por / Cambios
   ---------------------------------------------------
   0.03  23-May-2009  Eduardo Masia
                      Creada clase.
                      Completada clase
   0.03a 24-May-2009  Eduardo Masia
                      Eliminados for para diagonales y cambiados por triangulos.
 
 ---------------------------------------------------- */

namespace Damas
{
    class PresentacionLetras
    {
        private byte colorR;
        private byte colorG;
        private byte colorB;

        private sbyte incR;
        private sbyte incG;
        private sbyte incB;

        public PresentacionLetras()
        {
            colorR = 0xff;
            colorG = 0xff;
            colorB = 0xff;

            incR = 1;
            incG = 2;
            incB = 3;
        }


        public void IncrementarColores()
        {
            if ((colorR + incR) > 255 || (colorR + incR) < 0)
            {
                incR = (sbyte)-incR;
            }
            colorR += (byte)incR;

            if ((colorG + incG) > 255 || (colorG + incG) < 0)
            {
                incG = (sbyte)-incG;
            }
            colorG += (byte)incG;

            if ((colorB + incB) > 255 || (colorB + incB) < 0)
            {
                incB = (sbyte)-incB;
            }
            colorB += (byte)incB;
        }


        public void DibujarA(short x, short y, float factor)
        {
            // Barra central
            Hardware.RectanguloRellenoRGBA((short)(x - (20 * factor)),
                                           (short)(y + (10 * factor)),
                                           (short)(x + (20 * factor)),
                                           (short)(y + (30 * factor)),
                                           colorR, colorG, colorB, 0xff);

            // Barra central \
            Hardware.TrianguloRellenoRGBA((short)(x - (10 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x + (10 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x + (20 * factor)),
                                          (short)(y + (50 * factor)),
                                           colorR, colorG, colorB, 0xff);
            Hardware.TrianguloRellenoRGBA((short)(x + (10 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x + (20 * factor)),
                                          (short)(y + (50 * factor)),
                                          (short)(x + (40 * factor)),
                                          (short)(y + (50 * factor)),
                                           colorR, colorG, colorB, 0xff);

            // Barra central /
            Hardware.TrianguloRellenoRGBA((short)(x - (10 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x + (10 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x - (20 * factor)),
                                          (short)(y + (50 * factor)),
                                          colorR, colorG, colorB, 0xff);
            Hardware.TrianguloRellenoRGBA((short)(x - (10 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x - (20 * factor)),
                                          (short)(y + (50 * factor)),
                                          (short)(x - (40 * factor)),
                                          (short)(y + (50 * factor)),
                                           colorR, colorG, colorB, 0xff);
        }


        public void DibujarD(short x, short y, float factor)
        {
            // Barra superior
            Hardware.RectanguloRellenoRGBA((short)(x - (20 * factor)),
                                           (short)(y - (50 * factor)),
                                           (short)(x + (10 * factor)),
                                           (short)(y - (20 * factor)),
                                           colorR, colorG, colorB, 0xff);

            // Barra inferior
            Hardware.RectanguloRellenoRGBA((short)(x - (20 * factor)),
                                           (short)(y + (20 * factor)),
                                           (short)(x + (10 * factor)),
                                           (short)(y + (50 * factor)),
                                           colorR, colorG, colorB, 0xff);

            // Barra izquierda
            Hardware.RectanguloRellenoRGBA((short)(x - (40 * factor)),
                                           (short)(y - (50 * factor)),
                                           (short)(x - (20 * factor)),
                                           (short)(y + (50 * factor)),
                                           colorR, colorG, colorB, 0xff);

            // Circulo derecha
            Hardware.PieRGBA((short)(x + (10 * factor)),
                             (short)(y + (0 * factor)),
                             (short)(50 * factor),
                             -120,
                             120,
                             colorR, colorG, colorB, 0xff);
        }


        public void DibujarM(short x, short y, float factor)
        {
            // Barra izquierda
            Hardware.RectanguloRellenoRGBA((short)(x - (40 * factor)),
                                           (short)(y - (50 * factor)),
                                           (short)(x - (20 * factor)),
                                           (short)(y + (50 * factor)),
                                           colorR, colorG, colorB, 0xff);

            // Barra derecha
            Hardware.RectanguloRellenoRGBA((short)(x + (20 * factor)),
                                           (short)(y - (50 * factor)),
                                           (short)(x + (40 * factor)),
                                           (short)(y + (50 * factor)),
                                           colorR, colorG, colorB, 0xff);

            // Barra central \
            Hardware.TrianguloRellenoRGBA((short)(x - (40 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x - (20 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x - (10 * factor)),
                                          (short)(y + ( 0 * factor)),
                                           colorR, colorG, colorB, 0xff);
            Hardware.TrianguloRellenoRGBA((short)(x - (20 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x - (10 * factor)),
                                          (short)(y + ( 0 * factor)),
                                          (short)(x + (10 * factor)),
                                          (short)(y + ( 0 * factor)),
                                           colorR, colorG, colorB, 0xff);

            // Barra central /
            Hardware.TrianguloRellenoRGBA((short)(x + (40 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x + (20 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x + (10 * factor)),
                                          (short)(y + ( 0 * factor)),
                                          colorR, colorG, colorB, 0xff);
            Hardware.TrianguloRellenoRGBA((short)(x + (20 * factor)),
                                          (short)(y - (50 * factor)),
                                          (short)(x + (10 * factor)),
                                          (short)(y + ( 0 * factor)),
                                          (short)(x - (10 * factor)),
                                          (short)(y + ( 0 * factor)),
                                           colorR, colorG, colorB, 0xff);

        }


        public void DibujarS(short x, short y, float factor)
        {
            // Barra superior
            Hardware.RectanguloRellenoRGBA((short)(x-(10 * factor)),
                                           (short)(y-(50 * factor)),
                                           (short)(x+(30 * factor)),
                                           (short)(y-(30 * factor)),
                                           colorR, colorG, colorB, 0xff);

            // Circulo izquierdo
            Hardware.PieRGBA((short)(x - (10 * factor)),
                             (short)(y - (20 * factor)),
                             (short)(30 * factor),
                             60,
                             300,
                             colorR, colorG, colorB, 0xff);

            // Barra central
            Hardware.RectanguloRellenoRGBA((short)(x - (10 * factor)),
                                           (short)(y - (10 * factor)),
                                           (short)(x + (10 * factor)),
                                           (short)(y + (10 * factor)),
                                           colorR, colorG, colorB, 0xff);

            // Circulo derecho
            Hardware.PieRGBA((short)(x + (10 * factor)), 
                             (short)(y + (20 * factor)), 
                             (short)(30 * factor), 
                             -120, 
                             120,
                             colorR, colorG, colorB, 0xff);

            // Barra inferior
            Hardware.RectanguloRellenoRGBA((short)(x - (30 * factor)),
                                           (short)(y + (30 * factor)),
                                           (short)(x + (10 * factor)),
                                           (short)(y + (50 * factor)),
                                           colorR, colorG, colorB, 0xff);
        }


        public void ImprimirNombre(float fact, int cont)
        {
            short x = 500;
            short y = 370;

            if (cont < 10)
                return;

            if (cont == 10)
            {
                if (fact > 0.1)
                    Hardware.CaracterRGBA(x, y, 'E', colorR, colorG, colorB, 0xff);
                if (fact > 0.2)
                    Hardware.CaracterRGBA((short)(x + 10), y, 'd', colorR, colorG, colorB, 0xff);
                if (fact > 0.3)
                    Hardware.CaracterRGBA((short)(x + 20), y, 'u', colorR, colorG, colorB, 0xff);
                if (fact > 0.4)
                    Hardware.CaracterRGBA((short)(x + 30), y, 'a', colorR, colorG, colorB, 0xff);
                if (fact > 0.5)
                    Hardware.CaracterRGBA((short)(x + 40), y, 'r', colorR, colorG, colorB, 0xff);
                if (fact > 0.6)
                    Hardware.CaracterRGBA((short)(x + 50), y, 'd', colorR, colorG, colorB, 0xff);
                if (fact > 0.7)
                    Hardware.CaracterRGBA((short)(x + 60), y, 'o', colorR, colorG, colorB, 0xff);
                if (fact > 0.8)
                {
                    Hardware.CaracterRGBA((short)(x + 80), y, 'M', colorR, colorG, colorB, 0xff);
                    Hardware.CaracterRGBA((short)(x + 90), y, '.', colorR, colorG, colorB, 0xff);
                }
                if (fact > 0.9)
                {
                    Hardware.CaracterRGBA((short)(x + 110), y, 'R', colorR, colorG, colorB, 0xff);
                    Hardware.CaracterRGBA((short)(x + 120), y, '.', colorR, colorG, colorB, 0xff);
                }
            }
            else
            {
                Hardware.CaracterRGBA(x, y, 'E', colorR, colorG, colorB, 0xff);
                Hardware.CaracterRGBA((short)(x + 10), y, 'd', colorR, colorG, colorB, 0xff);
                Hardware.CaracterRGBA((short)(x + 20), y, 'u', colorR, colorG, colorB, 0xff);
                Hardware.CaracterRGBA((short)(x + 30), y, 'a', colorR, colorG, colorB, 0xff);
                Hardware.CaracterRGBA((short)(x + 40), y, 'r', colorR, colorG, colorB, 0xff);
                Hardware.CaracterRGBA((short)(x + 50), y, 'd', colorR, colorG, colorB, 0xff);
                Hardware.CaracterRGBA((short)(x + 60), y, 'o', colorR, colorG, colorB, 0xff);
                Hardware.CaracterRGBA((short)(x + 80), y, 'M', colorR, colorG, colorB, 0xff);
                Hardware.CaracterRGBA((short)(x + 90), y, '.', colorR, colorG, colorB, 0xff);
                Hardware.CaracterRGBA((short)(x + 110), y, 'R', colorR, colorG, colorB, 0xff);
                Hardware.CaracterRGBA((short)(x + 120), y, '.', colorR, colorG, colorB, 0xff);
            }
        }
    }
}
